package com.j170502.cateringmange.controller;

import com.j170502.cateringmange.entity.Place;
import com.j170502.cateringmange.entity.State;
import com.j170502.cateringmange.entity.Tables;
import com.j170502.cateringmange.service.PlaceService;
import com.j170502.cateringmange.service.StateService;
import com.j170502.cateringmange.service.TablesService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class TablesController {
    @Resource
    private TablesService tablesService;
    @Resource
    private PlaceService placeService;
    @Resource
    private StateService stateService;
    @RequestMapping("/first")
    public String showtables(Model model){
       List<Tables> listTables=tablesService.findAll();
       List<Place> listPlace=placeService.findAll();
       List<State> listState=stateService.findAll();
       model.addAttribute("listTables",listTables);
       model.addAttribute("listPlace",listPlace);
       model.addAttribute("listState",listState);
       return "home";
    }

    @RequestMapping("/findTables")
    @ResponseBody
    public List<Tables> findTables(int place,int state){
        return tablesService.findTables(place,state);
    }
}
